package com.example.androidpractice;

import android.content.Intent;
import android.os.Bundle;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;

import com.example.androidpractice.databinding.ActivityMainBinding;
import com.example.androidpractice.lifecycle.MyActivityObserver;
import com.example.androidpractice.model.Person;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;


public class MainActivity extends AppCompatActivity {

    @BindView(R.id.btn_ok)
    Button btnOk;
    @BindView(R.id.tv_hello)
    TextView tvHello;
    Person user = new Person("chenxsa", 40);

    @BindView(R.id.button)
    Button button;
    @BindView(R.id.button3)
    Button button3;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ActivityMainBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_main);

        binding.setPerson(user);
        ButterKnife.bind(this);
        //ButterKnife.bind(this);
    }

    @OnClick(R.id.btn_ok)
    public void onViewClicked() {
        user.setAge(18);
        user.setName("young chenxsa");
        //以下代码无用
        tvHello.setText("hello,click");
        Toast.makeText(this, user.toString(), Toast.LENGTH_SHORT).show();
    }

    @OnClick(R.id.button)
    public void onOpenUserViewClicked() {
        Intent intent = new Intent(this, UserListActivity.class);
        startActivity(intent);
    }

    @OnClick(R.id.button3)
    public void onBtn3Clicked() {
        Intent intent = new Intent(this, LifeCycleExampleActivity.class);
        startActivity(intent);
    }
}
